#pragma once

#include<string>

/**
 * @file ia.h
 *
 * @brief Wrapper class of Apache ap_base64
 * @see https://raw.githubusercontent.com/dhamidi/apache-httpd-1.3.42/master/src/ap/ap_base64.c 
 *
 * @author cygia.com
 * Contact: lance.liao@cygia.com
 *
 */
static class Base64
{
public:
	static std::string Encode(unsigned char* pToEncode, int bytesToEncode);
	static int GetDecodeLen(std::string base64Str);
	static int Decode(std::string base64Str, unsigned char* pBuffer, int bufferSize);
	static std::string Decode(std::string base64Str);

private:
	static int base64decode_len(const char* bufcoded);
	static int base64decode(char* bufplain, const char* bufcoded);
	static int base64decode_binary(unsigned char* bufplain,
		const char* bufcoded);

	static int base64encode_len(int len);
	static int base64encode(char* encoded, const char* string, int len);
	static int base64encode_binary(char* encoded,
		const unsigned char* string, int len);

};

